package com.chixing.day15_map_file.work;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

public class WCount {
    public static void main(String[] args) {
        File file = new File("E:\\test2\\calcCharNum.txt");
        try {
            InputStream is = new FileInputStream(file);

            Map<Character,Integer> map = new HashMap<>();
            int len = 0;
            while ((len=is.read()) !=-1){
                char a = (char) len;
                int sum=1;
                if ((a>='A'&a<='Z')||(a>='a'&a<='z')){
                    if (map.containsKey(a))
                        sum+=map.get(a);
                    map.put(a,sum);
                }
            }
            is.close();

            for (Character i: map.keySet()){
                System.out.println(i+"("+map.get(i)+")");
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
